package com.example.array;

import org.checkerframework.checker.units.qual.A;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListDemo {

    public static void main(String[] args) {
        List<Person> personList = new ArrayList<>();
        personList.add(new Person("xrb",12));
        personList.add(new Person("zl",11));
       /* Iterator<Person> iterator = personList.iterator();
        while(iterator.hasNext()){
            iterator.next();
            iterator.remove();
        }*/
        personList.forEach(person -> {
            person.setName("许荣北");
        });
        System.out.println(personList);
    }
}

class Person{

    private String name;

    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}